function [chrom,obj,obj_con,chrom1]=updates1(weight,chrom,obj,newpoint,Z_new,Z,obj_con,new_con)
weight(weight==0)=0.00001; 
chrom1 = [];
if length(Z_new) == 4
    
    parta= [Z_new(1)-Z(2) Z_new(2)-Z(1) Z_new(3)-Z(4) Z_new(4)-Z(3)];
    partb = [weight(1)*parta(1) weight(1)*parta(2) weight(2)*parta(3) weight(2)*parta(4)];
    newobj = compare(partb,2);

    partc= [obj(1)-Z(2) obj(2)-Z(1) obj(3)-Z(4) obj(4)-Z(3)];
    partd = [weight(1)*partc(1) weight(1)*partc(2) weight(2)*partc(3) weight(2)*partc(4)];
    oldobj = compare(partd,2);

    compare1 = [newobj,oldobj];
    result = compare(compare1,1);
    
    if isequaln(obj_con,[0,0]) && isequaln(new_con,[0,0])
    
    if result == newobj
        chrom=newpoint;
        obj=Z_new;
        obj_con=[0,0];
    elseif result == [compare1(1) compare1(3)]
        chrom1 = newpoint;
    end
    elseif isequaln(new_con,[0,0]) 
            chrom=newpoint;
            obj=Z_new;
            obj_con=[0,0];
    elseif isequaln(obj_con,[0,0])
            obj_con=[0,0];
    else
          result1 = compare([obj_con new_con],1);
              if result1 == new_con
                chrom=newpoint;
                obj=Z_new;
                obj_con=new_con;
              end   
    end    
end
    if length(Z_new) == 6
        
        parta= [Z_new(1)-Z(2) Z_new(2)-Z(1) Z_new(3)-Z(4) Z_new(4)-Z(3) Z_new(5)-Z(6) Z_new(6)-Z(5)];
        partb = [weight(1)*parta(1) weight(1)*parta(2) weight(2)*parta(3) weight(2)*parta(4) weight(3)*parta(5) weight(3)*parta(6)];
        newobj1 = compare(partb(1:4),2);         
        newobj = compare([newobj1,partb(5:6)],2);

        partc= [obj(1)-Z(2) obj(2)-Z(1) obj(3)-Z(4) obj(4)-Z(3) obj(5)-Z(6) obj(6)-Z(5)];
        partd = [weight(1)*partc(1) weight(1)*partc(2) weight(2)*partc(3) weight(2)*partc(4) weight(3)*partc(5) weight(3)*partc(6)];
        oldobj1 = compare(partd(1:4),2);
        oldobj = compare([oldobj1,partd(5:6)],2);

        compare1 = [newobj,oldobj];
        result = compare(compare1,1);
    if isequaln(obj_con,[0,0]) && isequaln(new_con,[0,0])
        if result == newobj
            chrom=newpoint;
            obj=Z_new;
            obj_con=[0,0];
        end
        elseif isequaln(new_con,[0,0]) 
                chrom=newpoint;
                obj=Z_new;
                obj_con=[0,0];
        elseif isequaln(obj_con,[0,0])
                obj_con=[0,0];
        else
              sum_newobj =  0.5*newobj + 0.5*new_con;
              sum_oldobj =  0.5*oldobj + 0.5*obj_con;
              compare2 = [sum_newobj,sum_oldobj]; 
              result1 = compare(compare1,1);
              if result1 == sum_newobj
                chrom=newpoint;
                obj=Z_new;
                obj_con=[0,0];
              end   

    end
end

